import { URL, ajax, Toast, getUser } from '../../../utils/index.js'
Page({
  data: {
    queryAssessList:[],
    endimgurl:'../../../../assets/end@2x.png',
    overimgurl:'../../../../assets/finish@2x.png',
  },
  btnsubmit(e){
    console.log(e)
    wx.navigateTo({
      url: `/pages/assess/assess?id=${e.currentTarget.dataset.index}`
    })
  },
  toExamineResult(e){ //考核结果页面跳转
    //状态 0:未完成 1：已完成 2:已结束
    let query = this.data.queryAssessList[e.currentTarget.dataset.index],status = query.status,navigateTo={};
    if(status == 0) return
    wx.navigateTo({
      url: `/pages/examineResult/examineResult?assessId=${query.assessId}&status=${query.status}`
    })
  },
  change(e){
    let query = this.data.queryAssessList[e.currentTarget.dataset.index],querystr=`queryAssessList[${e.currentTarget.dataset.index}]`
    query.status=2,this.setData({[querystr]:query})
  },
  onChange(e){
      this.setData({timeData: e.detail})
  },
  queryAssessList(){
    ajax.loading()
    return new Promise((resolve, reject) => {
        ajax.post('/applet/assess/queryAssessList').then(res => {
            if (res.data.code == 1) {
                resolve(res)
                this.setData({
                  queryAssessList: res.data.data.assessList
                })
                console.log(this.data.queryAssessList)
                ajax.toast.clear()
            } else ajax.toast.fail(res.data.msg), reject(res)
        }).catch(e => (ajax.toast.fail('接口错误onload'), reject(e), console.log(e)))
    })
  },
  onLoad: function (options) {
    this.queryAssessList()
  },







  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {}
})